package cn.edu.suda.catalina.health;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import java.util.Map;

public class ResultActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);

        TextView score = (TextView) findViewById(R.id.result_result);
        TextView advise = (TextView) findViewById(R.id.result_advise);

        Map<String, Integer> map = (Map<String, Integer>) getSharedPreferences("risk", MODE_PRIVATE).getAll();
        int result = 0;
        for (String key : map.keySet()) {
            if (!key.equals("X1") && !key.equals("X2")) {
                result += map.get(key);
            }
        }

        if (result <= 2) {
            score.setText("极低风险");
            advise.setText(getString(R.string.result_one));
        } else if (result >= 3 && result <= 5) {
            score.setText("低风险");
            advise.setText(getString(R.string.result_two));
        } else if (result >= 6 && result <= 7) {
            score.setText("中风险");
            advise.setText(getString(R.string.result_three));
        } else if (result >=8 && result <= 12) {
            score.setText("高风险");
            advise.setText(getString(R.string.result_four));
        } else {
            score.setText("极高风险");
            advise.setText(getString(R.string.result_five));
        }
    }
}
